package com.fjh.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjh.domain.ProdComm;
import com.fjh.service.ProdCommService;
import com.fjh.model.ProdCommVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("prod/prodComm")
@Api(tags = "商品的评论管理")
public class ProdCommController {

    @Autowired
    private ProdCommService prodCommService;

    @GetMapping("page")
    @ApiOperation("分页查询评论")
    public ResponseEntity<Page<ProdComm>> loadCommPage(Page<ProdComm>page,ProdComm prodComm){
        Page<ProdComm> prodCommPage = prodCommService.loadProdCommPage(page, prodComm);
        return ResponseEntity.ok(prodCommPage);
    }

    //-------------前台用户的

    @GetMapping("prodComm/prodCommData")
    @ApiOperation("根据用商品id查询评论总览")
    public ResponseEntity<ProdCommVo> findFrontProdComm(Long prodId){
        ProdCommVo prodCommVo= prodCommService.findFrontProdComm(prodId);
        return ResponseEntity.ok(prodCommVo);
    }

    @GetMapping("prodComm/prodCommPageByProd")
    @ApiOperation("分页查询单个商品的评论")
    public ResponseEntity<Page<ProdComm>> prodCommPageByProd(Long prodId,Page<ProdComm> page,Integer evaluate){
        Page<ProdComm> prodCommPage = prodCommService.prodCommPageByProd(prodId,page,evaluate);
        return ResponseEntity.ok(prodCommPage);
    }

}
